package map.blocks;

import game.models.Player;

import java.awt.Color;
import java.awt.Graphics;

import map.MapObject;
import map.PlayerEntity;
import map.RasterCell;

public class Teleporter extends MapObject {
	
	public Teleporter(){
		properties.put("targetX", "20");
		properties.put("targetY", "20");
	}

	@Override
	public boolean interact(Player actor) {
		return false;
	}

	@Override
	public boolean entered(Player actor) {
		int targetX = Integer.parseInt(properties.get("targetX"));
		int targetY = Integer.parseInt(properties.get("targetY"));
		
		System.out.println(targetX+"/"+targetY+ " - teleport activated");
		
		actor.setPositionX(targetX);
		actor.setPositionY(targetY);
		return true;
	}


	@Override
	public void deseriralize() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void paintComponent(Graphics arg0, RasterCell target) {
		arg0.setColor(Color.blue);
		arg0.fillOval(target.getCx()*target.RASTERSIZE, target.getCy()*target.RASTERSIZE, target.RASTERSIZE - 1, target.RASTERSIZE - 1);
	}

	@Override
	public MapObject newInstance() {
		return new Teleporter();
	}

	@Override
	public boolean enterable(Player actor) {
		return true;
	}

}
